class DishesService {
  async getDishes(params = {}) {
    const { page = 1, pageSize = 10, status, category } = params;
    
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 200,
          data: {
            list: [],
            total: 0,
            page,
            pageSize
          },
          message: 'success'
        });
      }, 500);
    });
  }

  async getDishById(id) {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 200,
          data: null,
          message: 'success'
        });
      }, 300);
    });
  }

  async createDish(data) {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 200,
          data: { ...data, id: Date.now().toString() },
          message: '菜品创建成功'
        });
      }, 500);
    });
  }

  async updateDish(id, data) {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 200,
          data: { ...data, id },
          message: '菜品更新成功'
        });
      }, 500);
    });
  }

  async deleteDish(id) {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 200,
          data: null,
          message: '菜品删除成功'
        });
      }, 500);
    });
  }

  async publishDish(id) {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 200,
          data: { id, status: 'online' },
          message: '菜品已上线'
        });
      }, 300);
    });
  }

  async unpublishDish(id) {
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve({
          code: 200,
          data: { id, status: 'offline' },
          message: '菜品已下线'
        });
      }, 300);
    });
  }

  async uploadImage(file) {
    return new Promise((resolve) => {
      setTimeout(() => {
        const url = URL.createObjectURL(file);
        resolve({
          code: 200,
          data: {
            url,
            name: file.name,
            size: file.size
          },
          message: '图片上传成功'
        });
      }, 1000);
    });
  }
}

export default new DishesService();